package com.smasher.component.activity

import android.annotation.SuppressLint
import android.content.Intent
import android.view.View
import androidx.activity.result.contract.ActivityResultContracts
import com.smasher.component.R
import com.smasher.component.databinding.ActivityMainBinding
import com.smasher.pdf.afreakyelf.AfreakyelfPdfActivity
import com.smasher.widget.base.BaseActivity

class MainActivity : BaseActivity(), View.OnClickListener {

    private lateinit var mBinding: ActivityMainBinding

    @SuppressLint("InflateParams")
    override fun getRootView(): View {
        mBinding = ActivityMainBinding.inflate(layoutInflater)
        return mBinding.root
    }

    override fun initView() {
        mBinding.function1.setOnClickListener(this)
        mBinding.function2.setOnClickListener(this)
        mBinding.function3.setOnClickListener(this)
        mBinding.function4.setOnClickListener(this)
        mBinding.function5.setOnClickListener(this)
        mBinding.function6.setOnClickListener(this)
        mBinding.function7.setOnClickListener(this)
        mBinding.function8.setOnClickListener(this)
        mBinding.function9.setOnClickListener(this)
        mBinding.function10.setOnClickListener(this)
        mBinding.function11.setOnClickListener(this)
    }


    override fun initData() {

    }

    override fun onClick(v: View) {
        when (v.id) {
            R.id.function1 -> gotoLocation()//gotoEncrypt()
            R.id.function2 -> gotoNative()
            R.id.function3 -> gotoNotification()
            R.id.function4 -> gotoDomain()
            R.id.function5 -> gotoUpdateVersion()
            R.id.function6 -> gotoDialog()
            R.id.function7 -> gotoSpinner()
            R.id.function8 -> gotoCamera()
            R.id.function9 -> gotoCamera2()
            R.id.function10 -> gotoPDFA()
            R.id.function11 -> gotoDecoration()
            else -> {}
        }
    }

    private fun gotoDecoration() {
        val intent = Intent()
        intent.setClass(this@MainActivity, DecorationActivity::class.java)
        launcher.launch(intent)
    }

    private fun gotoPDFA() {
        val intent = Intent()
        intent.setClass(this@MainActivity, AfreakyelfPdfActivity::class.java)
        launcher.launch(intent)
    }

    private fun gotoCamera() {
        val intent = Intent()
        intent.setClass(this@MainActivity, ScanActivity::class.java)
        launcher.launch(intent)
    }

    private fun gotoCamera2() {
        val intent = Intent()
        intent.setClass(this@MainActivity, CameraTestActivity::class.java)
        launcher.launch(intent)
    }


    private fun gotoSpinner() {
        val intent = Intent()
        intent.setClass(this@MainActivity, DemoActivity::class.java)
        launcher.launch(intent)
    }


    private fun gotoUpdateVersion() {
        val intent = Intent()
        intent.setClass(this@MainActivity, UpdateVersionActivity::class.java)
        launcher.launch(intent)
    }

    private fun gotoDialog() {
        val intent = Intent()
        intent.setClass(this@MainActivity, LoginAccess::class.java)
        launcher.launch(intent)
    }

    private fun gotoEncrypt() {
        val intent = Intent()
        intent.setClass(this@MainActivity, EncryptActivity::class.java)
        launcher.launch(intent)
    }

    private fun gotoNative() {
        val intent = Intent()
        intent.setClass(this@MainActivity, NativeActivity::class.java)
        launcher.launch(intent)
    }

    private fun gotoDomain() {
        val intent = Intent()
        intent.setClass(this@MainActivity, DomainTest::class.java)
        launcher.launch(intent)
    }

    private fun gotoNotification() {
        val intent = Intent()
        intent.setClass(this@MainActivity, NotificationActivity::class.java)
        launcher.launch(intent)
    }

    private fun gotoLocation() {
        val intent = Intent()
        intent.setClass(this@MainActivity, LocationActivity::class.java)
        launcher.launch(intent)
    }

    private val launcher =
        registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {

        }

    companion object {
        const val TAG = "Main"
    }
}